<?
	$name = isset($moduleSettings['items']['title']) ? $item[$moduleSettings['items']['title']] : $item['name'];
	$name = strip_tags($name);
	$name = strlen($name) > 30 ? substr($name, 0, 25) . '...' : $name;
?>
<h1>Hotspots</h1>
<?=Html::anchor((isset($backUrl) ? $backUrl : Request::$controller . 'item/' . $section . '/' . (isset($item['id']) ? $item['id'] . '/' : '')), '&larr; go back to ' . Html::chars($item['name']), array('class' => 'awesome'))?>
 <?=Html::anchor(Request::$controller . 'addHotspot/' . $section . '/' . $image['id'] . '/', 'Add hotspot', array('class' => 'awesome green'))?>
<br /><br />
<?php
	$size = Image::getSize(Model::factory('directory')->imagePath($image, 'hotmap'));
?>
<script type="text/javascript">
	swfobject.embedSWF("/flash/hotspots.swf", "hotmap-<?=$image['alias']?>", "100%", "100%", "9.0.0", "/flash/express-install.swf", {mode:"dashboard", xmlFile:"/hotmap/xml/<?=$image['section']?>/<?=$image['alias']?>/"});
</script>
<div style="width:<?=$size[0]?>px; height:<?=$size[1]?>px">
	<img src="<?=Model::factory('directory')->imagePath($image, 'hotmap')?>" width="<?=$size[0]?>" height="<?=$size[1]?>" alt="<?=Html::chars($image['name'])?>" id="hotmap-<?=$image['alias']?>"/>
</div>
<div style="margin-top: 10px;">
	<?if (count($hotspots)):?>
		<?=Html::anchor(Request::$controller . 'addHotspot/' . $section . '/' . $image['id'] . '/', 'Add hotspot', array('class' => 'awesome green'))?>
		<br /><br />
		<?$cnt = 0;?>
		<ul class="grid-sortable sortable">
			<?foreach ($hotspots as $hotspot):?>
				<li id="hotspots_<?=$hotspot['id']?>" style="border: solid 1px #ccc; padding: 10px; height: 150px; width: 450px; overflow: auto;">
					<? if ($hotspot['resolution']): ?>
						<div style="float: left; padding-right: 10px;">
							<?=Html::anchor(
								Model::factory('directory')->hotspotPath($hotspot, 'hotspot'),
								'<img src="' . Model::factory('directory')->hotspotPath($hotspot, 'tiny') . '" width="128" height="128" alt="' . Html::chars($hotspot['name']) . '"/>'
							)?>
						</div>
					<? endif; ?>
					<div style="padding-left: 140px;">
						<?if (
							isset($moduleSettings['items']['hotspots']['sorting']) ?
							$moduleSettings['items']['hotspots']['sorting'] :
							false
						):?>
								<span class="sortable-handler"><img src="/images/icons/16/sort4.png" width="16" height="16" /></span>
						<?endif?>
						<? if ($hotspot['name']): ?>
							<strong><?=($cnt + 1)?>. <?=Html::chars($hotspot['name'])?></strong>
							<br />
						<? endif; ?>
						<? if ($hotspot['text1']): ?>
							<div style="font-size:.85em; line-height: 1.2em;margin-bottom: 5px; color: #666;"><?=Html::chars($hotspot['text1'])?></div>
						<? endif; ?>
						- <?=Html::anchor(Request::$controller . 'defineHotspot/' . $section . '/' . $hotspot['id'] . '/', 'Define hotspot on image')?>
						<br />
						<?if (
							isset($moduleSettings['hotspots']['actions']['edit']) ?
							$moduleSettings['hotspots']['actions']['edit'] :
							true
						):?>
							- <?=Html::anchor(Request::$controller . 'editHotspot/' . $section . '/' . $hotspot['id'] . '/', 'Edit hotspot')?>
							<br />
						<?endif?>
						<?if (
							isset($moduleSettings['hotspots']['actions']['delete']) ?
							$moduleSettings['hotspots']['actions']['delete'] :
							true
						):?>
							- <?=Html::anchor(Request::$controller . 'removeHotspot/' . $section . '/' . $hotspot['id'] . '/', 'Remove hotspot'	)?>
							<br />
						<?endif?>
					</div>
					<div class="clear"></div>
				</li>
				<? $cnt++; ?>
			<?endforeach?>
		</ul>
	<?endif?>
</div>
<div class="clear"></div>